package com.tyl.lock;

public class SynchronizeDemo {
    public static void main(String[] args) {
        Phone phone=new Phone();
        new Thread(()->{
            phone.sms();
        },"钥匙1开").start();

        new Thread(()->{
            phone.sms();
        },"钥匙2开").start();
    }
}

class Phone{
    public synchronized void sms(){
        System.out.println(Thread.currentThread().getName()+"大门");
        call();
    }
    public synchronized void call(){
        System.out.println(Thread.currentThread().getName()+"卧室门");
    }
}
